import { ID } from '@/types'
import { request } from '@/utils/request'

export function getAll () {
  return request.get('/boss/role/all')
}

export function createOrUpdate (data: object) {
  return request.post('/boss/role/saveOrUpdate', data)
}
export function getInfo (id: ID) {
  return request.get(`/boss/role/${id}`)
}
export function removeRole (id: ID) {
  return request.delete(`/boss/role/${id}`)
}
export function allocateUserRoles (userId: ID, roleIdList: ID[]) {
  return request.post('/boss/role/allocateUserRoles', { userId, roleIdList })
}

export function getAllResources (roleId: ID) {
  return request.get('/boss/resource/getRoleResources', { params: { roleId } })
}

export function allocateResources (roleId: ID, resourceIdList: ID[]) {
  return request.post('/boss/resource/allocateRoleResources', { roleId, resourceIdList })
}
